//
// Created by jsjxsy on 2022/9/9.
//
#include <iostream>
using namespace std;
void func1() {
  size_t v1 = 42;
  auto f = [v1]() -> int { return v1; };
  v1 = 0;
  auto j = f();
  cout << "j = " << j << endl;
}

void func2() {
  size_t v1 = 42;
  auto f = [&v1]() -> int { return v1; };
  v1 = 0;
  auto j = f();
  cout << "j = " << j << endl;
}

void func3() {
  size_t v1 = 42;
  auto f = [v1]()mutable { return ++v1; };
  v1 = 0;
  auto j = f();
  cout << "j = " << j << endl;
}

void func4() {
  size_t v1 = 42;
  auto f = [&v1] { return ++v1; };
  v1 = 0;
  auto j = f();
  cout << "j = " << j << endl;
}

int main() {
  //省略()->
  auto f = [] { return 42; };
  cout << f() << endl;

  func1();
  func2();
  func3();
  func4();
  return 0;
}